<template>
  <a-modal
    title="发货记录"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :footer="null"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-card :bordered="false">
      
      <s-table
        ref="table"
        size="default"
        :columns="columns"
        :data="loadData"
        :alert="true"
        :rowKey="(record) => record.code"
        :rowSelection="null"
        :showPagination="false"
      >

        <span slot="action" slot-scope="text, record">
          <a @click="$refs.deliverModal.show(record)">明细</a>
        </span>
      </s-table>
    </a-card>
    <deliver-modal ref="deliverModal" @ok="()=>{ $emit('ok');  $refs.table.refresh()}"/>
  </a-modal>
</template>

<script>
import {STable} from '@/components'
import {page} from '@/api/modular/main/emsorder/emsOrderManage'
import FcUpload from '@/components/FCUpload/FcUpload'
import DeliverModal from '@/views/main/productStorehouse/productDeliverOrderCompleted/deliverModalCanEdit'

export default {
  components: {
    DeliverModal,
    FcUpload,
    STable,
  },
  
  data: function () {
    return {
      labelCol: {
        xs: {span: 24},
        sm: {span: 3}
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 18}
      },
      form: this.$form.createForm(this),
      advanced: false, // 高级搜索 展开/关闭
      queryParam: {},  // 查询参数
      columns: [
        {
          title: '发货单号',
          dataIndex: 'orderNumber'
        },
        {
          title: '时间',
          dataIndex: 'createTime'
        },
        {
          title: '操作人',
          dataIndex: 'createUserName',
        },
        {
          title: '备注',
          dataIndex: 'remark',
        },
        {
          title: '操作',
          dataIndex: '',
          scopedSlots: {customRender: 'action'}
        },
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        return page(Object.assign(parameter, this.queryParam)).then((res) => {
          return res.data
        })
      },
      selectedRowKeys: [],
      selectedRows: [],
      defaultExpandedKeys: [],
      visible: false,
      confirmLoading: false,
      emsOrder: null,
      viewState: '',
      extra: {},
    }
  },
  computed: {},
  methods: {
    show(record) {
      this.visible = true
      this.emsOrder = record
      this.queryParam = {}
      this.queryParam.planOrderId = record.orderId
      this.queryParam.sourceOrderId = record.sourceOrderId
      this.queryParam.orderType = this.$businessEnum.ORDER_TYPE_ENUM.deliverOrder.id
      this.queryParam.pageSize = 99
      
      setTimeout(() => {
        this.handleOk()
      }, 100)
    },
    toggleAdvanced() {
      this.advanced = !this.advanced
    },
    handleOk() {
      this.$refs.table.refresh()
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    },
    handleSubmit() {
    },
    handleCancel() {
      this.visible = false
    },
  }
}
</script>

<style lang="less">
.table-operator {
  margin-bottom: 18px;
}

button {
  margin-right: 8px;
}
</style>
